package xhwl.insurance.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import java.util.ArrayList;

import xhwl.insurance.R;
import xhwl.insurance.http.bean.resp.SearchVideoResp;

/**
 * Created by fuyi on 2017/9/28.
 */

public class SearchAdapter extends BaseAdapter {

    private Context context;
    private ArrayList<SearchVideoResp> mList;

    public SearchAdapter(Context context,ArrayList<SearchVideoResp> mList) {
        super();
        this.context = context;
        this.mList = mList;
    }


    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public SearchVideoResp getItem(int position) {
        return mList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if(convertView == null){
            holder = new ViewHolder();
            convertView = LinearLayout.inflate(context, R.layout.item_search, null);
            holder.aloneview_txt = (TextView) convertView.findViewById(R.id.aloneview_txt);
            convertView.setTag(holder);
        }else{
            holder = (ViewHolder) convertView.getTag();
        }
        holder.aloneview_txt.setText(mList.get(position).getVIDEO_NAME());
        return convertView;
    }

    class ViewHolder{
        TextView aloneview_txt;
    }
}
